<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getRandomIntInclusive(min, max) {
            min = Math.ceil(min);
            max = Math.floor(max);
            return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值，含最小值 
        }

        // 生成包含最大值和最小值的随机数
        function getRandomNum(min, max) {
            return parseInt(Math.random() * (max - min + 1)) + min;
        }
        let num = getRandomNum(1, 100),
            inputNum;
        console.log(num);
        while (true) {
            inputNum = prompt('请输入要猜的数字[1-100]([按00]退出游戏)：');
            if (inputNum == '00') {
                break;
            } else if (inputNum > num) {
                alert('猜大了');
            } else if (inputNum < num) {
                alert('猜小了');
            } else if (inputNum == num) {
                alert('猜对了');
                break;
            } else {
                alert('输入格式错误');
            }
        }
    </script>
</body>

</html>